<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title></title>
    <script src="js/template.js" type="text/javascript" charset="utf-8"></script>
</head>
<body>
    <div id="wp"></div>
    <script id="tpl" type="text/html">
      <ul>
       <%for(var i in items){%>   
       <li>
        name:<%=items[i].name%>    val:<%=items[i].val%>
    </li>
    <%}%>
</ul>
</script>
<script src="../template.js"></script>
<script>
  var data={
    items:[{'name':'名字一','val':'数据一'},
    {'name':'名字二','val':'数据二'},
    {'name':'名字三','val':'数据三'},
    {'name':'名字四','val':'数据四'}
    ]
}
var html = template(document.getElementById('tpl').innerHTML,data);
document.getElementById('wp').innerHTML = html;
</script>
</body>
</html>